set mem 550m
set matsize 5000
log using "G:\whalley\projects\college_spending\programs\analysis\RESTAT_final\table8.log", replace
#delimit ;
set more 1;
*
* TABLE8.DO
* BY Alex Whalley
* VERSION OF 07/10/09
*
*;
use "G:\whalley\projects\college_spending\data\clean\restat_randr\cbp_college_all_lmt_analysis_ld_v4.dta", replace;
*
* DROP SMALL COUNTIES
*;
drop if totpop < 250000;
*
* REORMALIZE TOTAL EXPENDITURE TO BE $100k PER PERSON 
*;
gen ECFET3d1p = ECFET3d1 / 1000; 
drop ECFET3d1;
rename ECFET3d1p ECFET3d1;
gen ECFET5d1p = ECFET5d1 / 1000; 
drop ECFET5d1;
rename ECFET5d1p ECFET5d1;
gen endowl4_spindexd3d1_1 = endowl4_spindexd3d1 / 1000;
drop endowl4_spindexd3d1;
rename endowl4_spindexd3d1_1 endowl4_spindexd3d1;
gen endowl6_spindexd5d1_1 = endowl6_spindexd5d1 / 1000;
drop endowl6_spindexd5d1;
rename endowl6_spindexd5d1_1 endowl6_spindexd5d1;
*
* KEEP ONE OB PER COUNTY
*;
keep tot_ft_ug3d1 tot_ft_gr3d1 RDON3d1 PBUILDADD3d1 PEQUIPADD3d1  endowl4_spindexd3d1 
tot_ft_ug5d1  tot_ft_gr5d1 RDON5d1 PBUILDADD5d1 PEQUIPADD5d1  endowl6_spindexd5d1 
semp81 FIPSCOUNTY year;
collapse tot_ft_ug3d1 tot_ft_gr3d1 RDON3d1 PBUILDADD3d1 PEQUIPADD3d1  endowl4_spindexd3d1 
tot_ft_ug5d1 tot_ft_gr5d1 RDON5d1 PBUILDADD5d1 PEQUIPADD5d1  endowl6_spindexd5d1 
semp81, by(FIPSCOUNTY year);
replace semp81 = round(semp81);
*
* PART (1): 3 year
*; 
xi: reg tot_ft_ug3d1 endowl4_spindexd3d1 i.year [fw=semp81], cluster(FIPSCOUNTY);
test endowl4_spindexd3d1;
sum tot_ft_ug3d1 if endowl4_spindexd3d1 !=.;
xi: reg tot_ft_gr3d1 endowl4_spindexd3d1 i.year [fw=semp81], cluster(FIPSCOUNTY);
test endowl4_spindexd3d1;
sum tot_ft_gr3d1 if endowl4_spindexd3d1 !=.;
xi: reg RDON3d1 endowl4_spindexd3d1 i.year [fw=semp81], cluster(FIPSCOUNTY);
test endowl4_spindexd3d1;
sum RDON3d1 if endowl4_spindexd3d1 !=.;
xi: reg PBUILDADD3d1 endowl4_spindexd3d1 i.year [fw=semp81], cluster(FIPSCOUNTY);
test endowl4_spindexd3d1;
sum PBUILDADD3d1 if endowl4_spindexd3d1 !=.;
xi: reg PEQUIPADD3d1 endowl4_spindexd3d1 i.year [fw=semp81], cluster(FIPSCOUNTY);
test endowl4_spindexd3d1;
sum PEQUIPADD3d1 if endowl4_spindexd3d1 !=.;
*
* PART (2): 5 year
*; 
xi: reg tot_ft_ug5d1 endowl6_spindexd5d1 i.year [fw=semp81], cluster(FIPSCOUNTY);
test endowl6_spindexd5d1;
sum tot_ft_ug5d1 if endowl6_spindexd5d1 !=.;
xi: reg tot_ft_gr5d1 endowl6_spindexd5d1 i.year [fw=semp81], cluster(FIPSCOUNTY);
test endowl6_spindexd5d1;
sum tot_ft_gr5d1 if endowl6_spindexd5d1 !=.;
xi: reg RDON5d1 endowl6_spindexd5d1 i.year [fw=semp81], cluster(FIPSCOUNTY);
test endowl6_spindexd5d1;
sum RDON5d1 if endowl6_spindexd5d1 !=.;
xi: reg PBUILDADD5d1 endowl6_spindexd5d1 i.year [fw=semp81], cluster(FIPSCOUNTY);
test endowl6_spindexd5d1;
sum PBUILDADD5d1 if endowl6_spindexd5d1 !=.;
xi: reg PEQUIPADD5d1 endowl6_spindexd5d1 i.year [fw=semp81], cluster(FIPSCOUNTY);
test endowl6_spindexd5d1;
sum PEQUIPADD5d1 if endowl6_spindexd5d1 !=.;
*
* CLOSE LOG, CLEAR AND END
*;
log close;
*clear;